﻿// Copyright (c) Microsoft Corporation.  All rights reserved. 
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System;

namespace WiE.Model
{
    enum ChangeType
    {
        Updated,
        Added,
        Removed
    };

    class DataObjectChangedArgs : EventArgs
    {
        protected WiEDataObject m_wieDataObject = null;

        protected ChangeType m_changeType = ChangeType.Added;

        public DataObjectChangedArgs() { }

        public DataObjectChangedArgs(WiEDataObject p_wieDataObject) { m_wieDataObject = p_wieDataObject; }

        public DataObjectChangedArgs(WiEDataObject p_wieDataObject, ChangeType p_changeType) { m_wieDataObject = p_wieDataObject; m_changeType = p_changeType; }

        public WiEDataObject ObjectChanged
        {
            set { m_wieDataObject = value; }
            get { return m_wieDataObject; }
        }

        public ChangeType Change
        {
            set { m_changeType = value; }
            get { return m_changeType; }
        }
    }


    /// <summary>
    /// Base class for DataObjects (objects that represent business entities that can be retrieved and stored by DataModel).
    /// </summary>
    abstract class WiEDataObject
    {
        /// <summary>
        /// Each data object is responsible for proving a property that returns a unique id that identifies
        /// that instance.
        /// </summary>
        public abstract System.Guid UniqueId
        {
            get;
        }

        /// <summary>
        /// A DataObject has to know how to turn itself to a property bag.  Preferably keeping to basic property types to ensure compatibility with
        /// various marshalling mechanisms (Strings, Decimal, Dates)
        /// </summary>
        /// <returns></returns>
        public abstract Dictionary<string, object> ToPropertyDictionary();
    }
}
